#pragma once

#include <string>
#include <vector>
#include "json_serialize.h"
#include "rapidjson/prettywriter.h"
#include "rapidjson/rapidjson.h"
#include "rapidjson/document.h"
#include "rapidjson/stringbuffer.h"
#include "rapidjson/writer.h"
#include "rapidjson/memorystream.h"
#include "include/rapidjson/writer.h"
#include "include/rapidjson/stringbuffer.h"
#include <iostream>

using namespace std;
using namespace rapidjson;

class Teacher : public JsonSerialize {
    public:
        Teacher() = default;
        ~Teacher() = default;


        virtual void ParseToJson(Writer<StringBuffer> &writer) {
            writer.StartObject();               // Between StartObject()/EndObject(), 
            writer.Key("name");                // output a key,
            writer.String(name.c_str());             // follow by a value.
            writer.Key("id");
            writer.Int(id);
            writer.Key("stds");
            writer.StartArray();
            for (auto &i : stds) {
                i.ParseToJson(writer);
            }
            writer.EndArray();
            writer.Key("favStd");
            favStd.ParseToJson(writer);
            writer.EndObject();
        };

        Teacher(string _name, int _id, vector<Student> &_stds, Student _favStd): name(_name), id(_id), favStd(_favStd) {
            stds = _stds;
        }
    private:
        string name;
        int id;
        vector<Student> stds;
        Student favStd;
};